{% extends "base.html" %}
{% block content %}
<center>
	<h3>Choose server</h3>
	<p>	
		<form action="{{ action }}" method="post">
			<input type="hidden" id="service" value="{{service}}">
			<a class="ui-button ui-widget ui-corner-all" title="Return back" onclick="history.back()">Back</a>
			{% include 'include/select.html' %}
			<button type="submit" value="open" name="open" class="btn btn-default">Open</button>
		</form>
	</p>
	{% if not aftersave %}
		{% if stderr or error %}
			{% include 'include/errors.html' %}
		{% endif %}
	{% endif %}
	{% if open %}
		<center>
			<h4>Choose old version</h4>
			<p>
				<select autofocus required name="configver" id="configver">
					<option disabled selected>Choose version</option>
						{% for file in return_files %}
							{% if file == configver %}
								<option value="{{file}}" selected>{{file.split('-', maxsplit=1)[1]}}</option>
							{% else %}
								<option value="{{file}}">{{file.split('-', maxsplit=1)[1]}}</option>
							{% endif %}
						{% endfor %}
				</select>
				<input type="hidden" value="{{serv}}" name="serv">
				<input type="hidden" value="open" name="open">
				<input type="hidden" value="{{service}}" name="service" id="service">
				<a class="ui-button ui-widget ui-corner-all" id="show" title="Enter" onclick="showUploadConfig()">Select</a>
			</p>		
		</center>
	{% endif %}
	{% if aftersave %}
		<div class="alert alert-info">Was uploaded old version of config: {{ configver }} </div>
		{% if stderr or error %}
			{% include 'include/errors.html' %}	
		{% else %}
			<div class="alert alert-success">Config is ok</div>
			<a href="viewsttats.py?serv={{ serv }}" target="_blank" title="View stats">Go to view stats</a>
		{% endif %}

	{% endif %}
</center>
{% if aftersave != 1 %}
	<script> 
		showUploadConfig()
	</script> 
{% endif %}
{% endblock %}